<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>BirthdayReminder | Start</title>
<link href="css/mystyles.css" rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<f:view locale="#{languageBean.activeLocale}">
<div align="center">
<h:form id="navform">
<p><h:commandLink id="start" value="#{msg.NavStart}" action="#{startpageBean.doNavigate}"><f:param name="nav" value="start"/></h:commandLink> | 
<h:commandLink id="contacts" value="#{msg.NavContacts}" action="#{startpageBean.doNavigate}"><f:param name="nav" value="contacts"/></h:commandLink> | 
<h:commandLink id="calendar" value="#{msg.NavCalendar}" action="#{startpageBean.doNavigate}"><f:param name="nav" value="calendar"/></h:commandLink> | 
<h:commandLink value="#{msg.NavLogout}" action="#{logoutBean.doLogout}"/></p>
</h:form>
<h1>#{msg.startWelcome}</h1>
<!--<p>
<b>Hint for new Users:</b><br/> 
On this page you can see the next few upcoming birthdays (at least if you've already added some contacts).
<br/>
If you chose to get notified via RSS-Feed, this page is the place where you can subscribe to the feed we generated for you.
<br/>
Furthermore you can view or edit your profile information.
<br/><br/>
To add, edit or delete contacts please go to the "my contacts"-page.
<br/><br/>
If you want to get an overview regarding the birthdays, please head to the "my calendar"-page.
</p> -->
<p>
<h:form id="birthdaysform">
<p:dataTable id="nextbirthdays" var="bday" value="#{startpageBean.comingBirthdays()}" rendered="#{startpageBean.comingBirthdays().size() gt 0 ? 'true' : 'false'}" emptyMessage="---" >
<f:facet name="header">#{msg.startNextBirthdays}</f:facet>
<p:column>
<h:outputText value="#{bday.dob lt 10 ? '0' : ''}#{bday.dob}.#{bday.mob lt 10 ? '0' : ''}#{bday.mob}." escape="false"/>
</p:column>
<p:column>
#{bday.name}
</p:column>
</p:dataTable>
</h:form>
</p>
<b>#{msg.startProfileInfoLabel}</b>
<h:form id="editprofile">
<table>
<!-- <tr>
<td>Username:</td>
<td><h:outputText value="#{startpageBean.puser}" id="profileusername"/></td>
</tr> -->
<tr>
<td>#{msg.startProfileInfoEMail}</td>
<td>
<h:outputText value="#{startpageBean.pemail}" id="profileemail" />
</td>
</tr>
<tr>
<td>#{msg.startProfileInfoNtype}</td>
<td>
<h:outputText value="#{startpageBean.pntype}" id="profilentype" />
</td>
</tr>
<tr>
<td><p:commandLink value="#{msg.startProfileInfoEdit}" action="#{startpageBean.editProfile()}" >
<p:ajax update=":formgroup" event="click"/>
</p:commandLink>
</td>
<td><p:commandLink value="#{msg.startProfileInfoChangePW}" >
<p:ajax update=":formgroup" async="true" listener="#{startpageBean.changePw}"/>
</p:commandLink>
</td>
</tr>
</table>
</h:form>

<h:panelGroup id="formgroup" >
<h:form id="pwform" rendered="#{startpageBean.changepwvisible}">
<fieldset>
<legend>#{msg.startPasswordLegend}</legend>
<h:messages styleClass="error" globalOnly="true"/>
<table>
<tr>
<td>#{msg.startPasswordPWLabel}</td>
<td><h:inputSecret id="newpassword" value="#{startpageBean.ppw}" required="true" requiredMessage="#{msg.startPasswordPWEmpty}"/><h:message id="m1" for="newpassword" styleClass="error" /></td>
</tr>
<tr>
<td>#{msg.startPasswordConfLabel}</td>
<td><h:inputSecret id="confnewpassword" value="#{startpageBean.pconfpw}" required="true" requiredMessage="#{msg.startPasswordConfEmpty}"/><h:message id="m2" for="confnewpassword" styleClass="error" /></td>
</tr>
<tr>
<td><p:commandButton value="#{msg.startPasswordSave}" action="#{startpageBean.doPwChange()}" id="pwsave" update=":formgroup"/>
</td>
<td><p:commandButton value="#{msg.startPasswordCancel}" action="#{startpageBean.cancelPwChange()}" immediate="true" id="pwcancel">
<f:ajax render=":formgroup" /></p:commandButton></td>
</tr>
</table>
</fieldset>
</h:form>


<h:form id="editform" rendered="#{startpageBean.editprofilevisible}">
<fieldset>
<legend>Edit Profile Information</legend>
<table>
<tr>
<td>E-Mail:</td>
<td>
<h:inputText id="pemail" required="true" requiredMessage="#{msg.startEmailError}" validatorMessage="#{msg.startEmailPatternError}">
<f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />
</h:inputText>
</td>
</tr>
<tr>
<td>Notificationtype:</td>
<td>
<h:selectOneMenu id="pntype" required="true" requiredMessage="#{msg.startNtypeError}" validatorMessage="#{msg.startNtypeError}" >
  	<f:selectItem id="noselection" noSelectionOption="true" itemLabel="- - -" />
    <f:selectItems value="#{startpageBean.ntypelist}" var="type" itemValue="#{type.getId()}" itemLabel="#{type.getType()}"/>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td><h:commandButton value="Save" action="#{startpageBean.doEditProfile()}"/></td>
<td><h:commandButton value="Cancel" action="#{startpageBean.cancelEditProfile()}" immediate="true" >
<f:ajax render=":formgroup" /></h:commandButton></td>
</tr>
</table>
</fieldset>
</h:form>
</h:panelGroup>
</div>
</f:view>
</h:body>
</html>